<?php

class BuildingsPlugin {
    var $ld;
    var $xmlsOb;
	var $cntCops;
    var $copsRequired;
    var $bot;
    var $translate;
    var $LangNotice;
    var $XMLtransl;

    function BuildingsPlugin() {
     $this->ld = new LocalData();
	 $this->xmlsOb = new xmlsOb();
     $bot = new Bot();
     $SetLangauge = $bot->GetParamByName("language");

     $LangPath = 'Plugins/Buildings/lang/';
     $disableNotices = TRUE; //FALSE; // TRUE for production, so no errors are shown.
     $LangRoute = array( 'de' => 'en', 'es' => 'en', 'fr' => 'en', 'tr' => 'en', 'it' => 'en', 'pt' => 'en', 'nl' => 'en', 'da' => 'en', 'nb' => 'en', 'pl' => 'en', 'ru' => 'en' );
     $this->translate = new Zend_Translate( array('adapter' => 'tmx', 'content' => $LangPath, 'locale'  => 'en', 'route' => $LangRoute , 'disableNotices' => $disableNotices));
     $this->translate->setLocale($SetLangauge);

     if (!$this->translate->isAvailable($SetLangauge))
       { // not available languages are rerouted to english
         $this->LangNotice = "Your language is not (yet) available. We use English where needed.<br>";
         $this->translate->setLocale('en');
       } else {$this->LangNotice = "";}

     // Create a log instance
     $writer = new Zend_Log_Writer_Stream('tmp_dir/Lang_Log/Buildings_Lang.log');
     $log    = new Zend_Log($writer);
     $this->translate->setOptions( array('log' => $log, 'logUntranslated' => true ));
     //now load the langauge from the game.xml
     $this->XMLtransl = new transl($SetLangauge);
      ///  $XMLtransl->langXML

    }
    function t($trans)
    {
      // look for translation in XML
      if ($this->translate->isAvailable($trans))
       {
         return  htmlentities($this->translate->_($trans), ENT_QUOTES, "UTF-8");
       }
       else
       {
         if(array_key_exists($trans, $this->XMLtransl->langXML)) return $this->XMLtransl->langXML[$trans];
         //_friendlyName
         $trans2 = $trans . "_friendlyName";
         if(array_key_exists($trans2, $this->XMLtransl->langXML)) return $this->XMLtransl->langXML[$trans2];

       }



      return  htmlentities($this->translate->_($trans), ENT_QUOTES, "UTF-8");
    }
    // ==========================================================================
    function GetXMLtime($time)
    {
      $tmptime = (string)$time*(23/24); // now the time is in days.
      $tmptime = $tmptime * 24 * 60 ; // now time is in min.
      if($tmptime >= 0 && $tmptime < 60){ $tmptime= round($tmptime, 1)." Min."; }
      if($tmptime >= 60 && $tmptime < 3600){ $tmptime= round($tmptime/60, 1)." Hour"; }
      if($tmptime >= 3660 && $tmptime < 86400){ $tmptime= round($tmptime/60/24, 1)." Day"; }
      $nicetime = $tmptime;
      return $nicetime;
    }
    // ==========================================================================
    function GetForm()
    {
      global $imagePath;
      $imagePath = substr($_SERVER["PHP_SELF"], 0, strpos($_SERVER["PHP_SELF"], "/"));
      $PlVersion = (array)$this->ld->GetPlVersion('buildings');
      $settings = (array) $this->ld->GetPlSettings('buildings');


      echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
           "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
           <html xmlns="http://www.w3.org/1999/xhtml" lang="ru">
           <head>
           <title>Buildings</title>
           <script src="..\..\codebase-php\jquery-1.4.2.min.js"></script>
           <script src="..\..\codebase-php\jquery.json-2.2.min.js"></script>
           <link href="helpers/plugin.css" rel="stylesheet" type="text/css">
           <style>
             #maint{ font-size: 10pt; width: 850px; padding: 0px; }
           </style>

           <script language="JavaScript" type="text/javascript">
           <!--
           var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);
           function addOption(theSel, theText, theValue)
           {
             var newOpt = new Option(theText, theValue);
             var selLength = theSel.length;
             theSel.options[selLength] = newOpt;
           }

           function deleteOption(theSel, theIndex)
           {
             var selLength = theSel.length;
             if(selLength>0)
             {
               theSel.options[theIndex] = null;
             }
           }

          function moveOptions(theSelFrom, theSelTo)
          {
            var selLength = theSelFrom.length;
            var selectedText = new Array();
            var selectedValues = new Array();
            var selectedCount = 0;
            var i;
            // Find the selected Options in reverse order and delete them from the from Select.
            for(i=selLength-1; i>=0; i--)
            {
              if(theSelFrom.options[i].selected)
              {
                selectedText[selectedCount] = theSelFrom.options[i].text;
                selectedValues[selectedCount] = theSelFrom.options[i].value;
                deleteOption(theSelFrom, i);
                selectedCount++;
              }
            }

            // Add the selected text/values in reverse order.
            // This will add the Options to the TO Select
            // in the same order as they were in the FROM Select.
            for(i=selectedCount-1; i>=0; i--)
            {
              addOption(theSelTo, selectedText[i], selectedValues[i]);
            }

            if(NS4) history.go(0);
          }
          //-->
          </script>


          <script language="javascript">
          <!-- For select images box
          function showimage() { if (!document.images) return
            document.images.pictures.src=document.mygallery.picture.options[document.mygallery.picture.selectedIndex].value }
          //-->
          </script>

          <script>
          function sortSelect(selElem) {
                var tmpAry = new Array();
                for (var i=0;i<selElem.options.length;i++) {
                        tmpAry[i] = new Array();
                        tmpAry[i][0] = selElem.options[i].text;
                        tmpAry[i][1] = selElem.options[i].value;
                }
                tmpAry.sort();
                while (selElem.options.length > 0) {
                    selElem.options[0] = null;
                }
                for (var i=0;i<tmpAry.length;i++) {
                        var op = new Option(tmpAry[i][0], tmpAry[i][1]);
                        selElem.options[i] = op;
                }
                return;
          }

          //==============================================================
          window.reload = function(){
             var l=window.location.toString();
             var indx=l.indexOf(\'?\');
             window.location=l.slice(0, indx)+"?action=refresh&tmp="+Math.random();
          }
          //==============================================================
          $(document).ready(
             function()
             {
               window.settings=eval(' . json_encode($this->ld->GetPlSettings('buildings')) . ');
               if ((window.settings!==null) && (window.settings!==undefined))
               {
 
                 $(":checkbox").each(
                    function(){
                      if(window.settings[$(this).attr("id")]==true){
                        $(this).attr("checked", true);
                      }
                      else{
                        $(this).attr("checked", false);
                      }
                    });
                 $(":radio").each(
                    function(){
                      if(window.settings[$(this).attr("id")]==true){
                        $(this).attr("checked", true);
                      }
                      else{
                        $(this).attr("checked", false);
                      }
                    });
                 $(":text").each(
                    function (){
                      var attr=$(this).attr("id");
                      if (window.settings[attr]!==null){
                        $(this).val(window.settings[attr]);
                      }
                      else{
                        $(this).val("0");
                      }
                    });
               }
               //==============================================================
               $("#btn_save").click(
                  function(){
                    var req=new Object();
                    $(":checkbox").each(
                       function(){
                         var par=$(this).attr("id");
                         req[par]=$(this).attr("checked");
                         if (($(this).attr("objid")!==null) && ($(this).attr("objid")!==undefined))
                         {
                           req[par+"ID"]=$(this).attr("objid");
                         }
                       });
                    $(":radio").each(
                       function(){
                         var par=$(this).attr("id");
                         req[par]=$(this).attr("checked");
                         if (($(this).attr("objid")!==null) && ($(this).attr("objid")!==undefined))
                         {
                           req[par+"ID"]=$(this).attr("objid");
                         }
                       });
                    $("input:text").each(function()
                    {
                      req[$(this).attr("id")]=$(this).val();
                    });

                    req.collectbbIN=new Array();
                    $("#collectbbIN option").each(
                       function(){
                         //var par=$(this).attr("id");
                         var par=$(this).val();
                         req.collectbbIN.push(par);
                         //req.collectbbIN.push($(this).attr("id")+""+$(this).text());
                       });
                    //req["collectbbIN"]=$("#collectRentIN  :selected").text();
                    req.collectRentIN=new Array();
                    $("#collectRentIN option").each(
                       function(){
                         var par=$(this).val();
                         req.collectRentIN.push(par);
                         //req.collectRentIN.push($(this).attr("id")+""+$(this).text());
                       });
                    req.collectMuIN=new Array();
                    $("#collectMuIN option").each(
                       function(){
                         var par=$(this).val();
                         req.collectMuIN.push(par);
                         //req.collectMuIN.push($(this).attr("id")+""+$(this).text());
                       });
                    req.collectLMIN=new Array();
                    $("#collectLMIN option").each(
                       function(){
                         var par=$(this).val();
                         req.collectLMIN.push(par);
                         //req.collectLMIN.push($(this).attr("id")+""+$(this).text());
                       });
					   
					req.collectCruiseIN=new Array();
                    $("#collectCruiseIN option").each(
                       function(){
                         var par=$(this).val();
                         req.collectCruiseIN.push(par);
                         //req.collectCruiseIN.push($(this).attr("id")+""+$(this).text());
                       });
					   
					req.collectPlaneIN=new Array();
                    $("#collectPlaneIN option").each(
                       function(){
                         var par=$(this).val();
                         req.collectPlaneIN.push(par);
                         //req.collectPlaneIN.push($(this).attr("id")+""+$(this).text());
                       });

                    data=$.toJSON(req);
                    var l=window.location.toString();
                    var indx=l.indexOf(\'?\');
                    var nurl=l.slice(0, indx)+"?action=save&tmp="+Math.random();
                    $.post(nurl, data);

                    return false;
               });
             });
          </script>

          </head>
          <body>
            <form name="mygallery">
            <div ><span class="error">'.$this->LangNotice.'</span></div>';
      //Announcement03_title
      //var_dump($this->XMLtransl->langXML);
      //echo 'test:  '.$this->t("Announcement03_title").'   <br>';
      //echo 'test:  '.$this->t("blabla").'   <br><br>';
      //var_dump($this->t("Announcement03_title"));
      //echo ' <br><br><br>';
	  //Collect rent modified by phreaker

//      echo  '    <h1>&nbsp;'.$this->t("Buildings").'&nbsp;'.$this->t("Version").':&nbsp; 1.0BETA (01.09.2011) </h1>
echo '      <table border="1" cellspacing="1" cellpadding="1" width="100%" bgcolor="#DAA520">
			    <tr height="23">
                    <td>
					    <hr><h1>'.$this->t("Buildings").'&nbsp;'.$this->t("v").$PlVersion['version'].'</h1>
                        <h5>REVAMPED by Tonycell, Updated by BQ (11.05.2012)</h5><hr>
				    </td>
                </tr>
			 </table>
			 <br>
            </div>
			
            <table border="1" cellspacing="1" cellpadding="1" width="100%" bgcolor="#ff0066">
                <tr height="23">
                    <td>
					    <h3><input type="checkbox" id="echeck">Auto-Check/Use Energy from your inventory?</h3>
				    </td>
                </tr>
            </table>			
            <br>
            <br>
            <table border="1" cellspacing="1" cellpadding="1" width="100%" bgcolor="#ff0066">
                <tr height="23">
                    <td>
					<h3>Residences</h3>
					</td>
                </tr>
            </table>
			<br>
            <input type="checkbox" id="collectrent">'.$this->t("Collect Residences").'?<br>
            <br>
			<table class="table66">
				<tr height="12">
					<td><b>Options</b>:</td>
						<td>
							<input type="checkbox" id="rentvacant">Collect Residences having vacant only?<br>
							<input type="checkbox" id="doggie">Try to capture Doggies<br>
							<input type="checkbox" id="Rbonus">Streak Bonus<br>
						</td>
				</tr>
			</table>
			<br>

						Select the Residences you like to collect:';

      if(!isset($settings['collectRentIN'])) $settings['collectRentIN'] = array();
      $resNOT="";
      $resN = array();
      $resIN="";
      $resI = array();
      $objects = $this->ld->GetObjects();
      foreach ($objects as $key=>$item)
      {
        //if ((string)$item['type'] == "residence")
        if ((string)$item['className'] == "Residence")

        {
          $found = "N";
          if (in_array((string)$item['id'],$settings['collectRentIN'])) {$found = "Y";}
          if($found == "Y" )
          { $resI[$item['id']] = (string)$item['itemName'];}
          else
          { $resN[$item['id']] = (string)$item['itemName'];}
        }
      }
      natcasesort($resI);
      natcasesort($resN);
      foreach ($resI as $id=>$item)
      {
		$obj = $this->ld->GetObjectById($id);
		$pop = $obj["currentPopulation"]*10;
		$popmax = $this->xmlsOb->GetResidencesMaxPopulation($item)*10;
		if ($pop == 0) { $pop = $this->xmlsOb->GetResidencesBasePopulation($item)*10; }
		$popstats = $pop." / ".$popmax;
		if ($popmax - $pop == 0) {$full = "(FULL) ";} else {$full = "";}
        $resIN .= '<option value="'.$id.'">'.$full.$item." ($id) : $popstats</option>";
      }
      foreach ($resN as $id=>$item)
      {
		$obj = $this->ld->GetObjectById($id);
		$pop = $obj["currentPopulation"]*10;
		if ($pop == 0) { $pop = $this->xmlsOb->GetResidencesBasePopulation($item)*10; }
		$popmax = $this->xmlsOb->GetResidencesMaxPopulation($item)*10;
		$popstats = $pop." / ".$popmax;
		if ($popmax - $pop == 0) {$full = "(FULL) ";} else {$full = "";}
        $resNOT .= '<option value="'.$id.'">'.$full.$item." ($id) : $popstats</option>";
      }
      echo  '<table class="table0">
            <th>Do NOT collect</th><th></th><th>Do collect</th></tr>
              <tr>
               <td>
                 <select name="sell1" size="10" multiple="multiple">';
      echo $resNOT;
      echo '     </select>
               </td>
               <td align="center" valign="middle">
                <input type="button" value="--&gt;"onclick="moveOptions(this.form.sell1, this.form.sell2); sortSelect(this.form.sell2)" /><br />
                <input type="button" value="&lt;--"onclick="moveOptions(this.form.sell2, this.form.sell1); sortSelect(this.form.sell1)" />
               </td>
               <td>
                 <select name="sell2" size="10" multiple="multiple" id="collectRentIN">';
      echo $resIN;
	  echo '   
              </td>
             </tr>
           </table>';
// CustomResidence ===========================================================================
     echo '<br>
           Avaliable CustomResidence:
           <table style="width: 100px; background-color: white;border-width: 1px;">
            <tr>
             <td><b>Collect</b></td>
             <td><b>Item</b></td>
             <td><b>ID</b></td>
			 <td><b>State</b></td>
			 <td><b><center>Population</center></b></td>
             <td><b><center>Max Population</center></b></td>
             <td><b><center>Vacancies</center></b></td>
             </tr>';
			 		
           $Objects = $this->ld->GetObjects();
           $i = 0;
           foreach ($Objects as $obj)
		       {
             //print_r($obj);
             //echo '<br>';
			       if($obj['className']=="CustomResidence")
             {
              echo '<tr>';
              switch ($obj['itemName']) {
			    case 'res_customresidences';
			    case 'res_customresidences_2';
			    case 'res_customresidences_3';
                case 'res_customresidences_4';
                case 'res_customresidences_5';
				$bgcolor = "E3E3E3";break 1;

              }
              echo '<td bgcolor="'.$bgcolor.'"><input type="checkbox" id="collectCustomResidence'.$i.'" objid="'.$obj['id'].'"></td>';$i++;
              echo '<td bgcolor="'.$bgcolor.'">'.$obj['itemName'].'</td>';
              echo '<td bgcolor="'.$bgcolor.'">'.$obj['id'].'</td>';

              if ($obj['state']=="grown")
              { echo '<td bgcolor="'.$bgcolor.'">Ready</td>'; }
              else
              { echo '<td bgcolor="'.$bgcolor.'">Not&nbsp;Ready</td>'; }
			  
			  $pop = $obj['currentPopulation']*10;
			  if ($pop == 0) {$pop = $this->xmlsOb->GetResidencesBasePopulation($obj['itemName'])*10;}
              echo '<td bgcolor="'.$bgcolor.'"><center>'.$pop.'</center></td>';

              $popmax = 0;
			  $popmax = $this->xmlsOb->GetResidencesMaxPopulation($obj['itemName']);
              if (is_array($obj['mechanicData']['slots'])){
              foreach($obj['mechanicData']['slots'] as $j=>$floor){
              if (!empty($floor)){
               $popmax += $this->xmlsOb->GetResidencesMaxPopulation($floor);
                    }
                 }
              }
              $popmax = $popmax * 10;
			  
              echo '<td bgcolor="'.$bgcolor.'"><center>'.$popmax.'</center></td>';
              $popdiff = $popmax - $pop;
              if ($popdiff == 0) $popdiff ="FULL";
              echo '<td bgcolor="'.$bgcolor.'"><center>'.$popdiff.'</center></td>';
			  echo '</tr>';
             }
           }
      echo '</table><br>';

		   
// Skyscraper ================================================================================	  
     echo '<br>
           Avaliable Skyscrapers:
           <table style="width: 100px; background-color: white;border-width: 1px;">
            <tr>
             <td><b>Collect</b></td>
             <td><b>Item</b></td>
             <td><b>ID</b></td>
			 <td><b>State</b></td>
			 <td><b><center>Population</center></b></td>
             <td><b><center>Max Population</center></b></td>
             <td><b><center>Vacancies</center></b></td>
             </tr>';
			 		
           $Objects = $this->ld->GetObjects();
           $i = 0;
           foreach ($Objects as $obj)
		       {
             //print_r($obj);
             //echo '<br>';
			       if($obj['className']=="Skyscraper")
             {
              echo '<tr>';
              switch ($obj['itemName']) {
			    case 'skyscraper_cetronas_center_1';
			    case 'skyscraper_cetronas_center_2';
			    case 'skyscraper_cetronas_center_3';
                case 'skyscraper_cetronas_center_4';
                case 'skyscraper_cetronas_center_5';
                case 'skyscraper_cetronas_center_6';
				$bgcolor = "E3E3E3";break 1;
				case 'sky_blueskyscraper_1';
			    case 'sky_blueskyscraper_2';
			    case 'sky_blueskyscraper_3';
                case 'sky_blueskyscraper_4';
                case 'sky_blueskyscraper_5';
                case 'sky_blueskyscraper_6';
				$bgcolor = "E3E3E3";break 1;
				case 'skyscraper_japanese_1';
			    case 'skyscraper_japanese_2';
			    case 'skyscraper_japanese_3';
                case 'skyscraper_japanese_4';
                case 'skyscraper_japanese_5';
                case 'skyscraper_japanese_6';
				$bgcolor = "E3E3E3";break 1;
				case 'skyscraper_dubai_1';
			    case 'skyscraper_dubai_2';
			    case 'skyscraper_dubai_3';
                case 'skyscraper_dubai_4';
                case 'skyscraper_dubai_5';
                case 'skyscraper_dubai_6';
				$bgcolor = "E3E3E3";break 1;
              }
              echo '<td bgcolor="'.$bgcolor.'"><input type="checkbox" id="collectsky'.$i.'" objid="'.$obj['id'].'"></td>';$i++;
              echo '<td bgcolor="'.$bgcolor.'">'.$obj['itemName'].'</td>';
              echo '<td bgcolor="'.$bgcolor.'">'.$obj['id'].'</td>';
			  

			  $harvestEndTS = $obj["mechanicData"]["harvestEndTS"];
							  
			  if($harvestEndTS > time()) {
			  $state = "Not&nbsp;Ready";
              }
			  else{
				$state = "Ready";
				  }
						
			  echo '<td bgcolor="'.$bgcolor.'">'.$state.'</td>';
			  
			  $pop = $obj['currentPopulation']*10;
			  if ($pop == 0) {$pop = $this->xmlsOb->GetResidencesBasePopulation($obj['itemName'])*10;}
              echo '<td bgcolor="'.$bgcolor.'"><center>'.$pop.'</center></td>';
              $popmax = $this->xmlsOb->GetResidencesMaxPopulation($obj["itemName"])*10;
              echo '<td bgcolor="'.$bgcolor.'"><center>'.$popmax.'</center></td>';
              $popdiff = $popmax - $pop;
              if ($popdiff == 0) $popdiff ="FULL";
              echo '<td bgcolor="'.$bgcolor.'"><center>'.$popdiff.'</center></td>';
			  echo '</tr>';
             }
           }
      echo '</table><br>';
// Neighbourhoods ================================================================================
     echo '<br>
           Avaliable Neighbourhoods:
           <table style="width: 100px; background-color: white;border-width: 1px;">
            <tr>
             <td><b>Collect</b></td>
             <td><b>Item</b></td>
             <td><b>ID</b></td>
			 <td><b>Energy</b></td>
             <td><b>State</b></td>		 
			 <td><b><center>Population</center></b></td>
             <td><b><center>Max Population</center></b></td>
             <td><b><center>Vacancies</center></b></td>
             </tr>';

           $Objects = $this->ld->GetObjects();
           $i = 0;
           foreach ($Objects as $obj)
		       {
             //print_r($obj);
             //echo '<br>';
			       if($obj['className']=="Neighborhood")
             {
              echo '<tr>';
              switch ($obj['itemName']) {
                case 'hood_apartments_level1';
                case 'hood_apartments_level2';
                case 'hood_apartments_level3';
                  $bgcolor = "FFB90F";break 1;
                  //echo '<td width="100"><input type="checkbox" id="hood_'.$i.'" objid="'.$obj['id'].'"></td>';$i++; break 1;
                case 'hood_vacation_homes_level1';
                case 'hood_vacation_homes_level2';
                case 'hood_vacation_homes_level3';
                  //echo '<td><input type="checkbox" id="hood_'.$i.'" objid="'.$obj['id'].'"></td>';$i++; break 1;
                  $bgcolor = "FFEC8B";break 1;
                case 'hood_gated_community_level1';
                case 'hood_gated_community_level2';
                case 'hood_gated_community_level3';
                  //echo '<td><input type="checkbox" id="hood_'.$i.'" objid="'.$obj['id'].'"></td>';$i++; break 1;
                  $bgcolor = "D2691E";break 1;
                case "hood_mansions_level1";
                case "hood_mansions_level2";
                case "hood_mansions_level3";
                  $bgcolor = "FFDEAD";break 1;
                case "hood_family2_level1";
                case "hood_family2_level2";
                case "hood_family2_level3";
                  $bgcolor = "D2691E";break 1;
				case "hood_familycomplex_level1";
                case "hood_familycomplex_level2";
                case "hood_familycomplex_level3";
                  $bgcolor = "D2691E";break 1;  
				case "hood_halloween";
                case "hood_halloween_level2";
                case "hood_halloween_level3";
                  $bgcolor = "CD96CD";break 1;
				case "hood_skyrise_level1";
                case "hood_skyrise_level2";
                case "hood_skyrise_level3";
                  $bgcolor = "FFB90F";break 1;
				case "hood_skiresort_level1";
                case "hood_skiresort_level2";
                case "hood_skiresort_level3";
                  $bgcolor = "EEE9E9";break 1;
				case "hood_holiday_level1";
                case "hood_holiday_level2";
                case "hood_holiday_level3";
                  $bgcolor = "EEE9E9";break 1;
				case "community_level1_district";
                case "community_level2_district";
                case "community_level3_district";
                  $bgcolor = "6DA4FF";break 1;
				case "hood_international_level1";
                case "hood_international_level2";
                case "hood_international_level3";
                  $bgcolor = "#C3A926";break 1;
              }
              echo '<td bgcolor="'.$bgcolor.'"><input type="checkbox" id="hood_'.$i.'" objid="'.$obj['id'].'"></td>';$i++;
              echo '<td bgcolor="'.$bgcolor.'">'.$obj['itemName'].'</td>';
              echo '<td bgcolor="'.$bgcolor.'">'.$obj['id'].'</td>';
              echo '<td bgcolor="'.$bgcolor.'">'.count($obj['mechanicData']['harvestState']['resources']).'</td>';
              $isgrown = true;
              foreach ((array) $obj['mechanicData']['slots'] as $k=>$house)
              {
                if ($house["state"] == 'grown') { $isgrown &= true; }
                else { $isgrown &= false; }
              }
              if ($isgrown) {echo '<td bgcolor="'.$bgcolor.'">Ready</td>';}
              else { echo '<td bgcolor="'.$bgcolor.'">Not&nbsp;ready</td>'; }


              $pop = 0;
			  $popmax = 0;
              foreach((array)$obj['mechanicData']['slots'] as $j=>$house)
			   {
               $popmax += $this->xmlsOb->GetResidencesMaxPopulation($house["itemName"]);
               $pop += $house["currentPopulation"];
			   if($house["currentPopulation"]==0) {$pop += $this->xmlsOb->GetResidencesBasePopulation($house["itemName"]);}
               }
			  $pop = $pop * 10;
              $popmax = $popmax * 10;
			  
              echo '<td bgcolor="'.$bgcolor.'"><center>'.$pop.'</center></td>';
              echo '<td bgcolor="'.$bgcolor.'"><center>'.$popmax.'</center></td>';
              $popdiff = $popmax - $pop;
              if ($popdiff == 0) $popdiff ="FULL";
              echo '<td bgcolor="'.$bgcolor.'"><center>'.$popdiff.'</center></td>';
			  echo '</tr>';

           }
         }
      echo '</table><br>';
// HOTELS ================================================================================
      echo '<table border="1" cellspacing="1" cellpadding="1" width="100%" bgcolor="#ff0066">
             <tr height="23">
              <td><h3>Hotels & Malls</h3></td>
             </tr>
           </table>';

      echo '
           Avaliable Hotels:
           <table class="table66" border="1" cellspacing="1" cellpadding="1" width="auto" bgcolor="#ff0066" style="table-layout=fixed">
            <tr>
             <td><b>Process</b></td>
             <td><b>Item</b></td>
             <td><b>Name</b></td>
             <td><b>Goods</b></td>
            </tr>';

           $Objects = $this->ld->GetObjects();
           //print_r($Objects);
           if (isset($Objects))
           foreach ($Objects as $obj)
		       {
             //print_r($obj);
             //echo '<br>';
			       if(($obj['className']=="Hotel") || ($obj['className']=="SocialBusiness"))
             {
              echo '<tr align="center" valign="middle">';
              switch ($obj['itemName']) {
                case 'resort_hotel_low';
                case 'resort_hotel_mid';
                case 'resort_hotel_large';
                   echo '<td width="100"><input type="checkbox" id="hotel_resort" objid="'.$obj['id'].'"></td>'; break 1;
                case 'hotel_sailboat_low';
                case 'hotel_sailboat_mid';
                case 'hotel_sailboat_large';
                   echo '<td><input type="checkbox" id="hotel_sailboat" objid="'.$obj['id'].'"></td>'; break 1;
                case 'tower_of_terror_regular';
                   echo '<td><input type="checkbox" id="hotel_terror" objid="'.$obj['id'].'"></td>'; break 1;
                case 'tiki_social_business': echo '<td><input type="checkbox" id="hotel_tiki" objid="'.$obj['id'].'"></td>'; break 1;
                case 'casino_social_business': echo '<td><input type="checkbox" id="hotel_casino" objid="'.$obj['id'].'"></td>'; break 1;
				case 'bus_lovehotel': echo '<td><input type="checkbox" id="hotel_honeymoon" objid="'.$obj['id'].'"></td>'; break 1;
              }
              echo '<td>'.$obj['itemName'].'</td>';
              echo '<td>'.$obj['mechanicData']['name'].'</td>';
              echo '<td>'.$obj['mechanicData']['harvestState']['customersReq'].'</td>';
              echo '</tr>';
             }
           }
     echo '</table>
           * Process = Visit &#187; Collect &#187; Supply
		   <br>';
// MALLS ================================================================================
     echo '<br>
           Avaliable Malls:
           <table style="width: 100px; background-color: white;border-width: 1px;">
            <tr>
             <td><b>Process</b></td>
             <td><b>Item</b></td>
			 <td><b>ID</b></td>
             <td><b>Energy</b></td>
             <td><b>Goods</b></td>
            </tr>';

           $Objects = $this->ld->GetObjects();
           $i = 0;
           foreach ($Objects as $obj)
		       {
             //print_r($obj);
             //echo '<br>';
			       if($obj['className']=="Mall")
             {
              echo '<tr>';
              switch ($obj['itemName']) {
                case 'mall';
                case 'mall_level2';
                case 'mall_level3';
				case 'mall_level4';
				case 'mall_level5';	
				$bgcolor = "E3E3E3";break 1;
                   //echo '<td width="100"><input type="checkbox" id="mall_" objid="'.$obj['id'].'"></td>'; break 1;
				case 'mall2';
                case 'mall2_level2';
                case 'mall2_level3';
				case 'mall2_level4';
				case 'mall2_level5';	
				$bgcolor = "BEBEBE";break 1;
				   //echo '<td width="100"><input type="checkbox" id="mall_" objid="'.$obj['id'].'"></td>'; break 1;
                case 'mall_food_court';
                case 'mall_food_court_level2';
				case 'mall_food_court_level3';
				$bgcolor = "B0B0B0";break 1;
				case 'mall_fashion_center';
                case 'mall_fashion_center_level2';
                case 'mall_fashion_center_level3';
				$bgcolor = "B0B0B0";break 1;
				   //echo '<td width="100"><input type="checkbox" id="mall_" objid="'.$obj['id'].'"></td>'; break 1;
				case 'mall_level1_district';
                case 'mall_level2_district';
                case 'mall_level3_district';
				$bgcolor = "6DA4FF";break 1;
				   //echo '<td width="100"><input type="checkbox" id="mall_" objid="'.$obj['id'].'"></td>'; break 1;
				case 'mall_solar';
                case 'mall_solar_level2';
                case 'mall_solar_level3';
				$bgcolor = "f7ff0a";break 1;
				 //echo '<td width="100"><input type="checkbox" id="mall_" objid="'.$obj['id'].'"></td>'; break 1;
              }
			  echo '<td bgcolor="'.$bgcolor.'"><input type="checkbox" id="mall_'.$i.'" objid="'.$obj['id'].'"></td>';$i++;
              echo '<td bgcolor="'.$bgcolor.'">'.$obj['itemName'].'</td>';
			  echo '<td bgcolor="'.$bgcolor.'">'.$obj['id'].'</td>';
              echo '<td bgcolor="'.$bgcolor.'">'.count($obj['mechanicData']['harvestState']['resources']).'</td>';
              echo '<td bgcolor="'.$bgcolor.'">'.$obj['mechanicData']['harvestState']['customersReq'].'</td>';

              echo '</tr>';
             }
           }
     echo '</table>
          * Process = Visit &#187; Collect &#187; Supply
		   <br>
           <br>';

//	 echo  '<br>
//            <table class="table66">
//            </tr>
//			  <tr height="12">
//              <td>REPEAT Y/N? <input type="checkbox" id="rcollectmall"></td>
//              <td>
//               <input type="text" id="rtimesmall" value="0" size="4">times<br>
//              </td>
//             </tr>';
// ThemePark ================================================================================
      echo '<table border="1" cellspacing="1" cellpadding="1" width="100%" bgcolor="#ff0066">
             <tr height="23">
              <td><h3>ThemePark</h3></td>
             </tr>
           </table>';

      echo '
           Avaliable ThemePark:
           <table class="table66" border="1" cellspacing="1" cellpadding="1" width="auto" bgcolor="#ff0066" style="table-layout=fixed">
            <tr>
             <td><b>Process</b></td>
             <td><b>Item</b></td>
             <td><b>Goods</b></td>
            </tr>';

           $Objects = $this->ld->GetObjects();
           //print_r($Objects);
           if (isset($Objects))
           foreach ($Objects as $obj)
		       {
             //print_r($obj);
             //echo '<br>';
			       if($obj['className']=="ThemePark")
             {
              echo '<tr align="center" valign="middle">';
              switch ($obj['itemName']) {
                case 'theme_park_level';
                case 'theme_park_level2';
                case 'theme_park_level3';
                   echo '<td width="100"><input type="checkbox" id="theme_park" objid="'.$obj['id'].'"></td>'; break 1;
              }
              echo '<td>'.$obj['itemName'].'</td>';
              echo '<td>'.$obj['mechanicData']['harvestState']['customersReq'].'</td>';
              echo '</tr>';
             }
           }
     echo '</table>
           * Process = Visit &#187; Collect &#187; Supply
           <br><br>';
// ZOO ===========================================================================================
      echo '
           <table border="1" cellspacing="1" cellpadding="1" width="100%" bgcolor="#ff0066">
            <tr height="23">
             <td><h3>Zoos</h3></td>
            </tr>
           </table>
           Avaliable Zoos:
           <table style="width: 100px; background-color: white;border-width: 1px;">
            <tr>
             <td><b>Collect</b></td>
             <td><b>Item</b></td>
             <td><b>State</b></td>
            </tr>';

           $Objects = $this->ld->GetObjects();
           $i = 0;
           foreach ($Objects as $obj)
		       {
             //print_r($obj);
             //echo '<br>';
			       if($obj['className']=="ZooEnclosure")
             {
              echo '<tr>';
              switch ($obj['itemName']) {
                case 'enclosure_jungle';
                case 'enclosure_savannah';
                case 'enclosure_mountain';
                case 'enclosure_arctic';
				$bgcolor = "E3E3E3";break 1;
              }
			  echo '<td bgcolor="'.$bgcolor.'"><input type="checkbox" id="zoo_'.$i.'" objid="'.$obj['id'].'"></td>';$i++;
              echo '<td bgcolor="'.$bgcolor.'">'.$obj['itemName'].'</td>';

              if ($obj['state']=="grown")
              { echo '<td bgcolor="'.$bgcolor.'">Ready&nbsp;to&nbsp;collect<td>'; }
              else
              { echo '<td bgcolor="'.$bgcolor.'">Not&nbsp;ready&nbsp;yet<td>'; }
              echo '</tr>';
             }
           }
      echo '</table><br>';

// PowerStation ================================================================
      echo '
           <table border="1" cellspacing="1" cellpadding="1" width="100%" bgcolor="#ff0066">
            <tr height="23">
             <td><h3>Power Station</h3></td>
            </tr>
           </table>';
      echo '
           Power Station:
           <table style="width: 100px; background-color: white;border-width: 1px;">
            <tr>
             <td><b>Collect</b></td>
             <td><b>Item</b></td>
             <td><b>ID</b></td>
             </tr>';

           $Objects = $this->ld->GetObjects();
           $i = 0;
           foreach ($Objects as $obj)
		       {
             //print_r($obj);
             //echo '<br>';
			       if($obj['className']=="PowerStation")
             {
              echo '<tr>';
              switch ($obj['itemName']) {
                case 'mun_dam';
                case 'pow_windmill';
                case 'pow_windmill';
                case 'mun_electricco';
                case 'mun_electricco_2';
				case 'mun_electricco_3';
				case 'mun_electricco_4';
				$bgcolor = "E3E3E3";break 1;
                   //echo '<td width="100"><input type="checkbox" id="power" objid="'.$obj['id'].'"></td>'; break 1;

              }
			  echo '<td bgcolor="'.$bgcolor.'"><input type="checkbox" id="power'.$i.'" objid="'.$obj['id'].'"></td>';$i++;
              echo '<td bgcolor="'.$bgcolor.'">'.$obj['itemName'].'</td>';
              echo '<td bgcolor="'.$bgcolor.'">'.$obj['id'].'</td>';
           }
         }
      echo '</table><br>';
// CRUISE SHIP ===================================================================================
//      echo '
//           <table border="1" cellspacing="1" cellpadding="1" width="100%" bgcolor="#ff0066">
//            <tr height="23">
//             <td><h3>Cruise Ship</h3></td>
//            </tr>
//           </table>
//           <input type="checkbox" id="cruise">Cruise Ship: Collect &#187; Supply ?<br>
//           <br>';
// BUSINESS ======================================================================================
      echo'<table border="1" cellspacing="1" cellpadding="1" width="100%" bgcolor="#ff0066">
            <tr height="23">
             <td><h3>Business</h3></td>
            </tr>
           </table>
           <br>
           Select the Business you like to collect/supply :';
      if(!isset( $settings['collectbbIN'])) $settings['collectbbIN'] = array();
      $resNOT="";
      $resN=array();
      $resIN="";
      $resI=array();
      //foreach ($xmlsOb->gsXML->items->item as $item)
      $objects = $this->ld->GetObjects();
      foreach ($objects as $key=>$item)
      {
        //if ((string)$item['type'] == "business")
        if (((string)$item['className'] == "Business") || (substr((string)$item['derivesFrom'],0,4) == "bus_"))
        {
          $found = "N";
          //foreach($settings['collectbbIN'] as $item2) { if((string)$item['itemName'] == $item2) {$found = "Y";} }
          if (in_array((string)$item['id'],$settings['collectbbIN'])) {$found = "Y";}
          if($found == "Y" )
          { $resI[$item['id']] = (string)$item['itemName'];}
          else
          { $resN[$item['id']] = (string)$item['itemName'];}
        }
      }
      natcasesort($resI);
      natcasesort($resN);
      foreach ($resI as $id=>$item)
      {	  
        $resIN .= '<option value="'.$id.'">'.$item." ($id)</option>";
      }
      foreach ($resN as $id=>$item)
      {	  
        $resNOT .= '<option value="'.$id.'">'.$item." ($id)</option>";
      }
      echo '&nbsp;&nbsp; <table class="table0">
            <th>Do NOT collect/supply</th><th></th><th>Do collect/supply</th></tr>
             <tr>
              <td>
               <select name="sel1" size="10" multiple="multiple">';
      echo $resNOT;
      echo '   </select>
              </td>
              <td align="center" valign="middle">
               <input type="button" value="--&gt;"onclick="moveOptions(this.form.sel1, this.form.sel2); sortSelect(this.form.sell2)" /><br />
               <input type="button" value="&lt;--"onclick="moveOptions(this.form.sel2, this.form.sel1); sortSelect(this.form.sell1)" />
              </td>
              <td>
               <select name="sel2" size="10" multiple="multiple" id="collectbbIN">';
      echo $resIN;
      echo '   </select>
              </td>
             </tr>
           </table>';

      echo  '<br>
            <table class="table66">
            <th align="left">Collecting</th><th align="left">Actions</th>
			       <tr height="12">
              <td>COLLECT Y/N? <input type="checkbox" id="collect"></td>
              <td>
               <input type="radio" id="collectbball" name="collect" value="collectbball" >Collect ALL business buildings.<br>
               <input type="radio" id="collectbb" checked name="collect" value="collectbb" >Collect ONLY business buildings from list.
              </td>
             </tr>
			       <tr height="12">
              <td>REPEAT Y/N? <input type="checkbox" id="rcollect"></td>
              <td>
               <input type="text" id="rtimes" value="0" size="4">times<br>
              </td>
             </tr>
             <tr height="12">
              <td>BEFORE Collect <br>Visiting Y/N? <input type="checkbox" id="process"></td>
              <td>&nbsp&nbsp&nbsp Make business buildings instant ready.<br>
              <input type="radio" id="supplybbplusall" checked name="process" value="supplybbplusall" >Visit ALL business buildings.<br>
              <input type="radio" id="supplybbplus" name="process" value="supplybbplus">Visit ONLY business buildings from list.
             </td>
             </tr>
             <tr height="12">
              <td>AFTER Collect <br>Supply Y/N? <input type="checkbox" id="supply"></td>
              <td>
               <input type="radio" id="supplybball" checked name="supply" value="supplybball" >Supply ALL business buildings with goods.<br>
               <input type="radio" id="supplybbball" checked name="supply" value="supplybbball" >Supply ALL business buildings with premium goods.<br>';
//             <input type="radio" id="supplybb" name="supply" value="supplybb" >Supply ONLY business buildings from list with goods.<br>
//             <input type="radio" id="supplybbb" name="supply" value="supplybbb" >Supply ONLY business buildings from list without goods.;
   echo'     </td>
             </tr>
             <tr height="12">
              <td>Extra</td>
              <td>
               <input type="checkbox" id="bandit">Try to capture bandits<br>
               <input type="checkbox" id="Bbonus" checked>Streak Bonus<br><hr>
			   <input type="checkbox" id="carsCollect">Collect Cars?<br>
			   <input type="checkbox" id="bridgeCollect">Collect Bridge?<br>
              </td>
             </tr>
			 </table>
			<b>Options</b>:
            <br>
            <input type="checkbox" id="actionTimedBusiness">Collect/Supply TimedBusiness
            <br>';
			 
// MunicipalCenter / Community Buildings / Landmarks ================================================================================
       echo'</table>
            <br>
            <table border="1" cellspacing="1" cellpadding="1" width="100%" bgcolor="#ff0066">
                <tr height="23">
                    <td><h3>MunicipalCenter / Community Buildings & Landmarks</h3></td>
                </tr>
            </table>
			<br>';
			
	  echo '<table class="table66">
			    <tr height="12">
			        <td><b>Options</b>:</td>
			        <td>
			            <input type="checkbox" id="CCbonus">Streak Bonus<br>
			        </td>
			    </tr>
			 </table>
			 <br>';
			
      echo '
           Avaliable MunicipalCenter:
           <table style="width: 100px; background-color: white;border-width: 1px;">
            <tr>
             <td><b>Collect</b></td>
             <td><b>Item</b></td>
             <td><b>ID</b></td>
			 <td><b>Energy</b></td>
             <td><b>State</b></td>
             </tr>';

           $Objects = $this->ld->GetObjects();
           $i = 0;
           foreach ($Objects as $obj)
		       {
             //print_r($obj);
             //echo '<br>';
			       if($obj['className']=="MunicipalCenter")
             {
              echo '<tr>';
              switch ($obj['itemName']) {
                case 'city_center_1';
                case 'city_center_2';
                case 'city_center_3';
				case 'city_center_4';
				case 'city_center_5';
                case 'city_center_6';				
                case 'city_center_7';	
				$bgcolor = "E3E3E3";break 1;
				case 'mun_govcenter';
                case 'mun_govcenter_2';
                case 'mun_govcenter_3';
				case 'mun_govcenter_4';
				case 'mun_govcenter_5';
                case 'mun_govcenter_6';				
                case 'mun_govcenter_7';	
				$bgcolor = "BEBEBE";break 1;
				case 'learning_center_1';
                case 'learning_center_2';
				$bgcolor = "A1A09A";break 1;
				case 'city_center_1_district';
                case 'city_center_2_district';
				case 'city_center_3_district';
				$bgcolor = "6DA4FF";break 1;
                   //echo '<td width="100"><input type="checkbox" id="MunCenter" objid="'.$obj['id'].'"></td>'; break 1;

              }
			  echo '<td bgcolor="'.$bgcolor.'"><input type="checkbox" id="MunCenter'.$i.'" objid="'.$obj['id'].'"></td>';$i++;
              echo '<td bgcolor="'.$bgcolor.'">'.$obj['itemName'].'</td>';
              echo '<td bgcolor="'.$bgcolor.'">'.$obj['id'].'</td>';
              echo '<td bgcolor="'.$bgcolor.'">'.count($obj['mechanicData']['harvestState']['resources']).'</td>';
              $isgrown = true;
              foreach ((array)$obj['mechanicData']['slots'] as $k=>$house)
              {
                if ($house["state"] == 'grown') { $isgrown &= true; }
                else { $isgrown &= false; }
              }
              if ($isgrown) {echo '<td bgcolor="'.$bgcolor.'">Ready&nbsp;to&nbsp;collect<td>';}
              else { echo '<td bgcolor="'.$bgcolor.'">Not&nbsp;ready&nbsp;yet<td>'; }
        echo '</tr>';
           }
         }
	  echo '</table><br>';

// ================================================================================			
      echo '<input type="checkbox" id="collectMu">'.$this->t("Collect Community Buildings").'?<br>
            <br>
            Select the Community Buildings you like to collect:';


      if(!isset($settings['collectMuIN'])) $settings['collectMuIN'] = array();
      $resNOT="";
      $resN = array();
      $resIN="";
      $resI = array();
      $objects = $this->ld->GetObjects();
      foreach ($objects as $key=>$item)
      {
        if ((string)$item['className'] == "Municipal" || (string)$item['className'] == "University")
        {
          $found = "N";
          if (in_array((string)$item['id'],$settings['collectMuIN'])) {$found = "Y";}
          if($found == "Y" )
          { $resI[$item['id']] = (string)$item['itemName'];}
          else
          { $resN[$item['id']] = (string)$item['itemName'];}
        }
      }
      natcasesort($resI);
      natcasesort($resN);
      foreach ($resI as $id=>$item)
      {
        $resIN .= '<option value="'.$id.'">'.$item." ($id)</option>";
      }
      foreach ($resN as $id=>$item)
      {
        $resNOT .= '<option value="'.$id.'">'.$item." ($id)</option>";
      }
      echo  '<table class="table0">
            <th>Do NOT collect</th><th></th><th>Do collect</th></tr>
              <tr>
               <td>
                 <select name="selll1" size="10" multiple="multiple">';
      echo $resNOT;
      echo '     </select>
               </td>
               <td align="center" valign="middle">
                <input type="button" value="--&gt;"onclick="moveOptions(this.form.selll1, this.form.selll2); sortSelect(this.form.selll2)" /><br />
                <input type="button" value="&lt;--"onclick="moveOptions(this.form.selll2, this.form.selll1); sortSelect(this.form.selll1)" />
               </td>
               <td>
                 <select name="selll2" size="10" multiple="multiple" id="collectMuIN">';
      echo $resIN;
	  echo '   
              </td>
             </tr>
           </table>';
      echo '<br>';

//	echo '		<input type="checkbox" id="collectLM">'.$this->t("Collect Landmarks").'?<br>
//            <br>';


      echo '<input type="checkbox" id="collectLM">'.$this->t("Collect Landmarks").'?<br>
            <br>
            Select the Landmarks you like to collect:';


      if(!isset($settings['collectLMIN'])) $settings['collectLMIN'] = array();
      $resNOT="";
      $resN = array();
      $resIN="";
      $resI = array();
      $objects = $this->ld->GetObjects();
      foreach ($objects as $key=>$item)
      {
        if ((string)$item['className'] == "Landmark")
        {
          $found = "N";
          if (in_array((string)$item['id'],$settings['collectLMIN'])) {$found = "Y";}
          if($found == "Y" )
          { $resI[$item['id']] = (string)$item['itemName'];}
          else
          { $resN[$item['id']] = (string)$item['itemName'];}
        }
      }
      natcasesort($resI);
      natcasesort($resN);
      foreach ($resI as $id=>$item)
      {
        $resIN .= '<option value="'.$id.'">'.$item." ($id)</option>";
      }
      foreach ($resN as $id=>$item)
      {
        $resNOT .= '<option value="'.$id.'">'.$item." ($id)</option>";
      }
      echo  '<table class="table0">
            <th>Do NOT collect</th><th></th><th>Do collect</th></tr>
              <tr>
               <td>
                 <select name="sellll1" size="10" multiple="multiple">';
      echo $resNOT;
      echo '     </select>
               </td>
               <td align="center" valign="middle">
                <input type="button" value="--&gt;"onclick="moveOptions(this.form.sellll1, this.form.sellll2); sortSelect(this.form.sellll2)" /><br />
                <input type="button" value="&lt;--"onclick="moveOptions(this.form.sellll2, this.form.sellll1); sortSelect(this.form.sellll1)" />
               </td>
               <td>
                 <select name="sellll2" size="10" multiple="multiple" id="collectLMIN">';
      echo $resIN;
	  echo '   
              </td>
             </tr>
           </table>';
      echo '<br>';

			
// ================================================================================			
  echo '     <table border="1" cellspacing="1" cellpadding="1" width="100%" bgcolor="#ff0066">
             <tr height="23">
              <td><h3>Trees</h3></td>
             </tr>
            </table>
            <input type="checkbox" id="ClearWildernes">'.$this->t("Clear Wildernes").'?<br>
            <br>
			<table border="1" cellspacing="1" cellpadding="1" width="100%" bgcolor="#ff0066">
             <tr height="23">
              <td><h3>'.$this->t("Santas Sleigh").'</h3></td>
             </tr>
            </table>
            <input type="checkbox" id="collectSleigh">'.$this->t("Collect Sleigh").'?<br><br>
            <table border="1" cellspacing="1" cellpadding="1" width="100%" bgcolor="#ff0066">
             <tr height="23">
              <td><h3>'.$this->t("Daily Bonus").'</h3></td>
             </tr>
            </table>
            <input type="checkbox" id="AcceptDayBonus">'.$this->t("Accept daily bonus").'<br>
            <br>
			
            <div width="100%" align="center"><hr>
            <button id="btn_save" style="color:white;background-color:#13a89e;border-width:1px;border-style:solid; ">&nbsp;'.$this->t("Save Settings").'&nbsp;</button>
            </div>
            <hr>
            </form>';
echo '<i>This page is available in: ';
//var_dump($this->translate->getList());
foreach($this->translate->getList() as $code )
 {
//  if($language == $code ){$selected = " SELECTED";}else{$selected = " ";}
  echo $this->t($code).' ';
 }
echo '</i><br>';
echo '    </body>
</html>
        ';
    }

}

?>